#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
#include<stdlib.h>
#include<assert.h>
typedef int SLTDateType;

typedef struct SListNode
{
	SLTDateType data;
	struct SListNode* next;
}SLTNode;

void SListPrint(SLTNode* phead)
{
	SLTNode* cur = phead;
	while (cur != NULL)
	{
		printf("%d ", cur->data);
		cur = cur->next;
	}
	printf("\n");
}
SLTNode* BuyListNode(SLTDateType x)
{
	SLTNode* newnode = (SLTNode*)malloc(sizeof(SLTNode));
	newnode->data = x;
	newnode->next = NULL;
	return newnode;
}
void SListPushBack(SLTNode** pphead, SLTDateType x)
{
	assert(pphead);
	SLTNode* newnode = BuyListNode(x);
	SLTNode* tail = *pphead;
	if (*pphead == NULL)
	{
		*pphead = newnode;
	}
	else
	{
		while (tail->next != NULL)
		{
			tail = tail->next;
		}
		tail->next = newnode;
	}
}

void removeList(SLTNode** pphead, int x)
{
	SLTNode* cur = *pphead;
	if (cur->data == x)
		return NULL;
	cur = (*pphead)->next;
	SLTNode* pre = *pphead;
	while (cur)
	{
		if (cur->data == x)
		{
			pre->next = cur->next;
			cur->next = *pphead;
			*pphead = cur;
			return;
		}
		else
		{
			pre = cur;
			cur = cur->next;
		}
	}
}

int main()
{
	SLTNode* phead = NULL;
	for (int i = 1; i <= 10; i++)
	{
		SListPushBack(&phead, i);
	}
	SListPrint(phead);
	int m = 0;
	scanf("%d", &m);
	int arr[10] = { 0 };
	for (int i = 0; i < m; i++)
	{
		scanf("%d", &arr[i]);
	}
	for (int i = 0; i < m; i++)
	{
		removeList(&phead, arr[i]);
		SListPrint(phead);
	}
	return 0;
}